using System;
using System.Text;
using System.Security.Cryptography;

namespace Portal.Data.Security
{
	public class Tools
	{
		/// <summary>
		/// Hash an input string using SHA_512
		/// first the input is converted to a bytes-array,
		/// after that the result is converted to base-64 string
		/// length (result) = (512/6)  
		/// </summary>
		/// <param name="input"></param>
		/// <returns></returns>
		public static string Hash (string input)
		{
			var encoder = new UnicodeEncoding();
			byte[] bytes = encoder.GetBytes(input);
			byte[] result = new SHA512Managed().ComputeHash(bytes);
			return Convert.ToBase64String(result);
		}
	}
}
